package com.supply.controller;

import com.supply.pojo.ResultBean;
import com.supply.req.LeaveBillGroup;
import com.supply.service.LeaveProcessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
@RequestMapping("/leaveProcess")
public class LeaveProcessController {
    @Autowired
    private LeaveProcessService leaveProcessService;

    @PostMapping("/startLeave")
    public ResultBean startLeave(@RequestBody LeaveBillGroup leaveBillGroup){
        System.out.println("请假信息：" + leaveBillGroup);
        leaveBillGroup.setLeaveDate(new Date());
        int rs = leaveProcessService.startLeave(leaveBillGroup);
        return rs >= 1 ? ResultBean.success() : ResultBean.error("服务器异常");
    }

}
